package com.luguangtao.controller;

import com.luguangtao.common.utils.FileService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;

@Controller
@CrossOrigin
public class FileController1 {


    @PostMapping("updateLoad")
    @ResponseBody
    public String uploadPic1(@RequestBody MultipartFile file) throws IOException {
        String originalFilename = file.getOriginalFilename();
        File file1 = new File("D:/pic" + File.separator + originalFilename);
        file.transferTo(file1);
        return originalFilename;
    }

    @RequestMapping("downLoad")
    public void downLoad1(HttpServletResponse response,HttpServletRequest request){
        FileService.downLoad(response,request);
    }
}
